<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>访问器属性</title>
</head>
<body>
<script>

    /*
    * JS中只有箭头函数和class的构造函数中是静态的  其他函数的this都是动态的 除非使用bind()进行固定绑定过
    *
    *
    * */


    let obj = {
        firstname: 'Ka',
        lastname: 'QW',

        get name() {
            return this.firstname + this.lastname
        },

        set name(name) {
            this.firstname = name.split("-")[0]
            this.lastname = name.split("-")[1]
        }

    }

    /*
    * 访问访问器属性其实是在调用函数 ----计算属性
    * */
    console.log(obj.name)
    obj.name = 'KIM-TOM'
    console.log(obj.name)

    Obj
</script>
</body>
</html>